package com.liruo.springframework.core.aop.springinterceptor;

import java.lang.reflect.Method;
import lombok.extern.slf4j.Slf4j;
import org.aopalliance.intercept.MethodInterceptor;
import org.aopalliance.intercept.MethodInvocation;

@Slf4j
public  class SimpleTraceMethodInterceptor implements MethodInterceptor {
private final String whatAdvisor;
  public SimpleTraceMethodInterceptor(String whatAdvisor) {
    this.whatAdvisor = whatAdvisor;
  }

  @Override
  public Object invoke(MethodInvocation invocation) throws Throwable {
    Method method = invocation.getMethod();
    log.info("{} invoke {}#{}",whatAdvisor,  method.getDeclaringClass().getSimpleName(), method.getName());
    return invocation.proceed();
  }
}